package com.project.sevice.impl;

import com.project.bean.ManBean;
import com.project.sevice.IManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/19 18:34
 */
@Controller
public class UpdateServlet extends HttpServlet {
    @Autowired
    private IManService service;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String id=req.getParameter("id");
        ManBean manBean=service.findById(Integer.parseInt(id));
        String birthday=req.getParameter("birthday");
        System.out.println(birthday);
        String str="<form action='http://localhost:8088/Gai' method='POST'>" +
                "姓名:"+manBean.getName()+"<br>" +
                "生日:<input type='date' name='birthday'><br>" +
                "<input type='submit' value='修改'>" +
                "<input type='hidden' name='id' value="+manBean.getId()+">"+
                "</form>";

        resp.getWriter().println(str);

    }
}
